<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html> 
<head>
<%@ include file="../../include/easyui.jsp" %>
<%@ include file="../../include/pGrid.jsp" %>
<title>附件管理</title>
<script>
	var pFn = {
			/*附件下载*/
			down: function(id){
				p.openWindowInHidden({url: '/console/download?id='+ id });
			},
			sizeFormart: function(size){
				var sizeType = (typeof size =='number') ;
				if(sizeType){
					if(size>=0 && size<1048576){
						size = (size/1024).toFixed(1) + "KB";
					}else{
						size = (size/1048576).toFixed(1) + "MB";
					}
				}
				return size;
			}
	};
	$(function(){
		var gridParam = {
			columns:[[
				{field:'type',title:'文件类型',width:80,formatter:function(value,row,index){
					var filetype = '.jpg|.gif|.png|.word|.txt|.rar|.zip|.doc|.docx|.xls|.xlsx|.pdf|.jpeg',
					value= value.toLowerCase();
					if(filetype.indexOf(value)>=0){
						value = value.substring(1)
						return '<img src="/images/file_'+ value+'.png"  alt="" />'
					}else{
						return '<img src="/images/file_other.png"  alt="" />'
					}
				}},  
	            {"field":"original","width":"300","title":"附件名称",formatter:function(value,row,index){
	            	var html = [];
	            	html.push('<p title="'+ value +'" >'+ value +'</p>');html.push('<p>'+ pFn.sizeFormart(row.size) +'</p>');
	            	return html.join('');
	            }},
	            {"field":"title","width":130,"title":"新名称"},
	            {"field":"url","width":250,"title":"完整路径"},
	            {"field":"state","width":80,"title":"上传状态"},
	            {"field":"opt","width":100,"title":"操作",formatter: function(value,row,index){
	            	return '<a href="#" onclick="pFn.down(\''+ row.id +'\')">下载</a>';
	            }}
			 ]]
		};
		p.dataGrid = $(p.dataGrid).datagrid( $.extend({}, p.dataGridParam,gridParam));

		/*事件响应*/
		$("#toolbar .easyui-linkbutton").on("click", function() {
			var motion_code = $(this).attr("motion_code");p.btnOneClick($(this));
			switch (motion_code) {
				case "05":
					p.gridQuery();
					break;
				default: break;
			}
		});
	});
</script>
</head>
<body class="easyui-layout">
	<!-- 但行高度33px，多行时 33乘以行数  -->
	<div data-options="region:'north',split:false,border:false" style="height:33px;">
		<div class="easyui-panel" data-options="fit:true,border:false">
			<!-- 查询条件表单，根据配置进行替换  -->
			<form id="queryForm" >
			 <input type="hidden" name="className" value="${className}" />
			 <div style="margin-top:5px;margin-left:10px;float:left;">
			  		<input class="easyui-textbox" name="original" style="width:240px;" data-options="label:'附件名:',required:false" />
					<input type="hidden" name="original_searchType" value="like" />
			 </div>
			 
			 <div class="fItem">
				  	<select class="easyui-combobox  easyui-validatebox" name="type" style="width:240px;" data-options="label:'文件类型:'"  >
					  	<option value="">==不限==</option>
					  	<option value="jpeg">jpeg</option>
					  	<option value="jpg">jpg</option>
					  	<option value="gif">gif</option>
					  	<option value="png">png</option>
					  	<option value="txt">txt</option>
					  	<option value="rar">rar</option>
					  	<option value="zip">zip</option>
					  	<option value="doc">doc</option>
					  	<option value="docx">docx</option>
					  	<option value="xls">xls</option>
					  	<option value="xlsx">xlsx</option>
					  	<option value="pdf">pdf</option>
					  </select>
					<input type="hidden" name="type_searchType" value="like" />
				 </div>
			</form>
		</div>
	</div>  

	<!-- 工具栏按钮 -->
	<div id="toolbar" class="easyui-panel" style="padding:3px;"></div>
	
	<!-- 表格 -->
	<div region="center" border="false">
		<table id="dataGrid"></table>
	</div>
</body>
</html>